/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package rule.occurance;

import java.util.HashSet;
import rule.Rule;

/**
 *
 * @author Daniel Gribel
 */
public class SpecialCharOccuranceRule extends OccuranceRule {
    
    private HashSet<Character> symbols;
    
    public SpecialCharOccuranceRule(int numDigits, int score) {
        super(numDigits, score);
        setScore(0);
        symbols = getSymbols();
    }    
    
    @Override
    public void checkConditions(String dataEntry) {
        super.checkConditions(dataEntry);
        setLog(getScore() + " points for at least " + getNumDigits() + " special chars");
    }

    @Override
    public boolean checkType(char character) {
        for (int j = 0; j < symbols.size(); j++) {
            if (symbols.contains(character))
                return true;
        }    
        return false;
    }
    
    @Override
    public String outputMessage() {
        return getLog();
    }
    
    private HashSet<Character> getSymbols() {
        HashSet<Character> symbols = new HashSet<Character>();
        symbols.add('!');
        symbols.add('@');
        symbols.add('#');
        symbols.add('$');
        symbols.add('%');
        symbols.add('^');
        symbols.add('&');
        symbols.add('*');
        symbols.add('?');
        symbols.add('_');
        symbols.add('~');
        return symbols;
    }

}
